package com.hut.oa.model.dao.announce;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.hut.oa.model.bean.AnnounceUser;
import com.hut.oa.model.bean.User;

public interface AnnounceUserDao extends PagingAndSortingRepository<AnnounceUser, Long>{

	Page<AnnounceUser> findByUser(@Param("user")User user,Pageable pageable);
	
	@Query("update AnnounceUser au set au.auIsRead=1 where au.auId=:id")
	@Modifying
	int updateRead(@Param("id")Long id);
	
	@Query("select count(au) from AnnounceUser au where au.user=:user and au.auIsRead=0")
	int noReadCount(@Param("user")User user);
}
